<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>cookie</title>
<script type="text/javascript" src="static/js/jquery.min.js"></script>
<style type="text/css">
	.form label{
		width: 70px;
		display: inline-block;
	}
	#send{
		border:1px solid grey;
		padding:5px 10px;
		display: inline-block;
		cursor: pointer;
	}
</style>
</head>
<body>
<div class="form">
	<p>
		<label>url:</label>
		<input type="text" name="url" id="toUrl" placeholder="www.test.com:8080" value="www.test.com:8080" />
	</p>
	<p>
		<label>token:</label>
		<input type="text" name="token" id="tokenVal" />
	</p>
	<p>
		<span id="send">写入Cookie</span>
	</p>
</div>

<script type="text/javascript">

	$(document).ready(function(){
		$("#send").on('click',function(){
			sendData($("#toUrl").val());
		});
	});
	
	function sendData(url){
		if(!!!url){
			alert('主机地址不能为空，请填写：www.example.com');
			return false;
		}
		if(!!!($("#tokenVal").val())){
			alert('token不能为空');
			return false;
		}
        $.ajax({  
            type: "post",  
            async: false,
            data : {token:$("#tokenVal").val()},
            url: "http://"+url+"/jsonp/CookieServlet",  
            dataType: "jsonp",  
            success: function(data){  
                if(true==data.success){
                	alert('写入成功');
                }else{
                	alert('写入失败');
                }
            },  
            error: function(){
                alert('fail');  
            }  
        });  
    }  
</script>
</body>
</html>